package com.craftplay.dao;

import com.craftplay.model.PayRedPackage;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

@Mapper
public interface PayRedPackageMapper {
    @Delete({
        "delete from pay_red_package",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into pay_red_package (id, outTradeNo, ",
        "redOutReadeNo, userId, ",
        "money, createTime, ",
        "status, payTime)",
        "values (#{id,jdbcType=INTEGER}, #{outtradeno,jdbcType=VARCHAR}, ",
        "#{redoutreadeno,jdbcType=VARCHAR}, #{userid,jdbcType=INTEGER}, ",
        "#{money,jdbcType=INTEGER}, #{createtime,jdbcType=TIMESTAMP}, ",
        "#{status,jdbcType=INTEGER}, #{paytime,jdbcType=TIMESTAMP})"
    })
    int insert(PayRedPackage record);

    @InsertProvider(type=PayRedPackageSqlProvider.class, method="insertSelective")
    int insertSelective(PayRedPackage record);

    @Select({
        "select",
        "id, outTradeNo, redOutReadeNo, userId, money, createTime, status, payTime",
        "from pay_red_package",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="outTradeNo", property="outtradeno", jdbcType=JdbcType.VARCHAR),
        @Result(column="redOutReadeNo", property="redoutreadeno", jdbcType=JdbcType.VARCHAR),
        @Result(column="userId", property="userid", jdbcType=JdbcType.INTEGER),
        @Result(column="money", property="money", jdbcType=JdbcType.INTEGER),
        @Result(column="createTime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="payTime", property="paytime", jdbcType=JdbcType.TIMESTAMP)
    })
    PayRedPackage selectByPrimaryKey(Integer id);

    @UpdateProvider(type=PayRedPackageSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(PayRedPackage record);

    @Update({
        "update pay_red_package",
        "set outTradeNo = #{outtradeno,jdbcType=VARCHAR},",
          "redOutReadeNo = #{redoutreadeno,jdbcType=VARCHAR},",
          "userId = #{userid,jdbcType=INTEGER},",
          "money = #{money,jdbcType=INTEGER},",
          "createTime = #{createtime,jdbcType=TIMESTAMP},",
          "status = #{status,jdbcType=INTEGER},",
          "payTime = #{paytime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(PayRedPackage record);


    @Select({
            "select",
            "id, outTradeNo, redOutReadeNo, userId, money, createTime, status, payTime",
            "from pay_red_package",
            "where status = #{status,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="outTradeNo", property="outtradeno", jdbcType=JdbcType.VARCHAR),
            @Result(column="redOutReadeNo", property="redoutreadeno", jdbcType=JdbcType.VARCHAR),
            @Result(column="userId", property="userid", jdbcType=JdbcType.INTEGER),
            @Result(column="money", property="money", jdbcType=JdbcType.INTEGER),
            @Result(column="createTime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
            @Result(column="payTime", property="paytime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<PayRedPackage> selectByStatus(int status);
}